﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GeneralClasses
{
    public class Nurse
    {
        #region variables
        private float hourlyWage;
        private int[] departments;
        private Skill[] skills;
        private DayOfWeek[] preferredDays;
        private Shift[] preferredShifts;
        private DateTime[] vacationDays;
        #endregion

        #region properties
        public float HourlyWage
        {
            get
            {
                return hourlyWage;
            }
            set
            {
                hourlyWage = value;
            }
        }

        public int[] Departments
        {
            get
            {
                return departments;
            }
            set
            {
                departments = value;
            }
        }

        public Skill[] Skills
        {
            get
            {
                return skills;
            }
            set
            {
                skills = value;
            }
        }

        public DayOfWeek[] PreferredDays
        {
            get
            {
                return preferredDays;
            }
            set
            {
                preferredDays = value;
            }
        }

        public Shift[] PreferredShifts
        {
            get
            {
                return preferredShifts;
            }
            set
            {
                preferredShifts = value;
            }
        }

        public DateTime[] VacationDays
        {
            get
            {
                return vacationDays;
            }
            set
            {
                vacationDays = value;
            }
        }
        #endregion

        #region constructor
        /// <summary>
        /// blank constructor
        /// </summary>
        public Nurse() { }

        #endregion


        #region private


        /// <summary>
        /// gets all the departments that this person is/can work in and returns an array full of them
        /// </summary>
        /// <param name="person">Person to be looked at</param>
        private int[] getPersonDepartments(Person person)
        {

            //make the list of all departments related to this person
            List<Department> depList = person.loadAllRelatedDepartments();
            
            //make an int array based on the same size
            int[] departments = new int[depList.Count];

            //add in all the department IDs from the list to the array
            for (int i = 0; i <= depList.Count - 1; i++)
            {
                departments[i] = depList.ElementAt(i).DepartmentID;
            }

            return departments; // return int[] array of department IDs
        }

        private Skill[] getPersonSkills(Person person) {
            //make the list of all departments related to this person
            List<Skill> skillList = person.loadSkills();

            //make an int array based on the same size
            Skill[] skills = new Skill[skillList.Count];

            //add in all the department IDs from the list to the array
            for (int i = 0; i <= skillList.Count - 1; i++)
            {
                skills[i] = skillList.ElementAt(i);
            }

            return skills; // return int[] array of department IDs
        }

        private Shift[] getPreferredShifts(Person person) {
            List<Shift> shifts = person.loadPreferredShifts();
            Shift[] preferred = new Shift[shifts.Count];

            for (int i = 0; i <= shifts.Count - 1; i++) {
                preferred[i] = shifts.ElementAt(i);
            }
            return preferred;
        }

        private DateTime[] getVacationDates(Person person) { 
            List<DateTime> list = person.loadVacationDates();

            DateTime[] dt = new DateTime[list.Count];

            for (int i = 0; i <= list.Count-1; i++) {
                dt[i] = list.ElementAt(i);
            }

            return dt;
        }

        #endregion

        #region public

        /// <summary>
        /// absorbs all the data from a Person object and collects it
        /// </summary>
        /// <param name="person">Person to be absorbed into the nurse class</param>
        public void absorbPerson(Person person)
        {
          //  hourlyWage = person.PayGrade.Wage;
            departments = getPersonDepartments(person);
            skills = getPersonSkills(person);
            
            //place in default junk day of weeks
            preferredDays = new DayOfWeek[7];
            preferredDays[0] = new DayOfWeek("Monday");
            preferredDays[1] = new DayOfWeek("Tuesday");
            preferredDays[2] = new DayOfWeek("Wednesday");
            preferredDays[3] = new DayOfWeek("Thursday");
            preferredDays[4] = new DayOfWeek("Friday");
            preferredDays[5] = new DayOfWeek("Saturday");
            preferredDays[6] = new DayOfWeek("Sunday");

            preferredShifts = getPreferredShifts(person);

            vacationDays = getVacationDates(person);
        }

        #endregion

    }
}
